package com.burgeon.backend.SHOP.rest;

/**
 * 修改vip专属导购
 */

import com.burgeon.backend.Rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

public class ModVipEmp extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public ModVipEmp(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符创
     */

    public void getData(String id, String emp, String storejh) throws Exception {
        System.err.println("id=" + id + "emp=" + emp+"storejh"+storejh);
        String url = "http://" + ip + "/servlets/binserv/Rest";
        String str = RESULT(Data(id, emp,storejh), url);
        System.err.println(str);
        String code = new JSONArray(str).getJSONObject(0).getString("code");
        String message = new JSONArray(str).getJSONObject(0).getString("message");
        if (!"0".equals(code)) {
            throw new Exception(message);
        }
    }

    private MultiValueMap Data(String id, String emp, String storejh) {

        HashMap params = new HashMap();

        params.put("ID", id);
        params.put("partial_update", "true");

        params.put("table", "C_VIP");//表名

        if (null != storejh && !"N".equals(storejh)) {
            params.put("'C_STOREJH_ID__NAME'", "'" + storejh + "'");
        }
        params.put("'HR_EMPLOYEE_ID1__NAME'", "'" + emp + "'");

        /*if (null!=store){
            params.put("'C_STORE_ID__NAME'",store);
        }*/


        return DATA("ObjectModify", params, account, password);
    }

    public static void main(String[] args) {
        ModVipEmp g = new ModVipEmp("39.99.239.133:55321", "nea@burgeon.com.cn", "burgeon55321");
        try {
//            id=49568emp=吴旭翠
            g.getData("49569", "吴旭翠","");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
